<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2019/4/24
 * Time: 16:00
 */

namespace app\admin\controller;


use think\Db;
use think\Request;

class Withdraw extends Base
{
    /**
     * 设置提现金额
     * @return mixed|\think\response\Json
     */
    public function updatePrice(){
        if(Request::instance()->isPost()){
            $price = input('price');
            if(!is_numeric($price)){
                return json(['code' => 100, 'msg' => '请输入数字']);
            }
            $res = Db::table('up_about_us')->where('about_id', 1)->update(['withdraw_price' => $price]);
            if($res){
                return json(['code' => 200, 'msg' => '编辑成功']);
            }else{
                return json(['code' => 100, 'msg' => '编辑失败']);
            }
        }
        $price = Db::table('up_about_us')->where('about_id', 1)->value('withdraw_price');
        $this->assign('price', $price);
        return $this->fetch('withdraw/updateprice');
    }
    /**
     * 设置达人任务超时时间
     * @return mixed|\think\response\Json
     */
    public function updatesupertime(){
        if(Request::instance()->isPost()){
            $price = input('price');
            if(!is_numeric($price)){
                return json(['code' => 100, 'msg' => '请输入数字']);
            }
            if($price < 48){
                return json(['code' => 100, 'msg' => '不能低于48小时']);
            }
            $res = Db::table('up_about_us')->where('about_id', 1)->update(['super_time' => $price]);
            if($res){
                return json(['code' => 200, 'msg' => '编辑成功']);
            }else{
                return json(['code' => 100, 'msg' => '编辑失败']);
            }
        }
        $price = Db::table('up_about_us')->where('about_id', 1)->value('super_time');
        $this->assign('price', $price);
        return $this->fetch('withdraw/updatesupertime');
    }
}